<%--
  Created by IntelliJ IDEA.
  User: wangjunneil@gmail.com
  Date: 13-12-17
  Time: 16:25
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/page/common/jsptag.jsp"%>
<html>
<head>
    <title></title>
    <link rel="stylesheet" href="<%=request.getContextPath() %>/bg/css/bg.css" type="text/css" />
    <script type="text/javascript" src="../../js/jquery-1.4.4.min.js"></script>
    <script type="text/javascript">
        function editParamValue(obj, id, key) {
            if (obj.editable) return;

            var input = document.createElement("input");
            input.type = 'text';
            input.style = 'height:' + obj.offsetHeight + 'px;width:' + obj.offsetWidth + 'px';
            input.value = obj.title;
            input.onkeydown = function() {
                var event = window.event || arguments[0];
                if (event.keyCode == 13) {
                    if (input.value == obj.title) {
                        obj.removeChild(input);
                        obj.innerHTML = input.value;
                        obj.editable = false;
                        return;
                    }
                    $.ajax({type:'POST', url:'updateSystemParam.html', data:'value=' + input.value + "&id=" + id + "&key=" + key});
                    obj.title = input.value;
                    obj.removeChild(input);
                    obj.innerHTML = input.value;
                    obj.editable = false;
                }
            }

            obj.editable = true;
            obj.replaceChild(input, obj.firstChild);
        }
    </script>
</head>
<body>
    <div id="listDiv">
        <table id="filmTable">
            <thead>
                <tr>
                    <th width="100">名称</th>
                    <th>值域</th>
                    <th width="50">标识</th>
                    <th width="200">说明</th>
                </tr>
            </thead>
            <tbody>
                <c:forEach var="system" items="${systemParamMap}">
                    <tr>
                        <td align="center">${system.value.paramName}</td>
                        <td title="${system.value.paramValue}"
                            ondblclick="editParamValue(this, ${system.value.id}, '${system.value.paramName}');">
                            <c:choose>
                                <c:when test="${fn:length(system.value.paramValue) > 50}">
                                    <c:out value="${fn:substring(system.value.paramValue, 0, 50)} ............" />
                                </c:when>
                                <c:otherwise>
                                    <c:out value="${system.value.paramValue}" />
                                </c:otherwise>
                            </c:choose>
                        </td>
                        <td align="center">
                            <c:choose>
                                <c:when test="${system.value.activeFlag == 0}">启用</c:when>
                                <c:otherwise>禁用</c:otherwise>
                            </c:choose>
                        </td>
                        <td>${system.value.detail}</td>
                    </tr>
                </c:forEach>
            </tbody>
        </table>
    </div>
</body>
</html>